angular.module('mamApp').factory('InitManger', ['$http', '$filter', function ($http, $filter) {
    var InitManger = {
        menuItem: function () {
            return $http.get("init/init.json").then(function (result) {
                return result.data;
            })
        },
        codeTable: function () {
            return $http.get("init/code.json").then(function (result) {
                return result.data;
            })
        },
        provinces: function () {
            return $http.get("init/province.json").then(function (result) {
                return result.data;
            })
        },
        /**
         * 缓存起来
         * @returns {*|IThenjsProto|IPromise<TResult>|IPromiseLike<TResult>}
         */
        cities: function () {
            return $http.get("init/city.json").then(function (result) {
                return result.data;
            })
        },
        /**
         * 通过省编码获取下面的城市
         * @param provinceID
         * @returns {*}
         */
        getCitiesByProId: function (provinceID) {
            var citys = JSON.parse(localStorage.getItem("city"));
            return $filter('filter')(citys, {provinceID: provinceID})
        }


    };

    return InitManger;
}]);
